package biz

import (
	"t11Lib/t11Errors"
	"亚太-iot-服务器/models"
)

var MqttMsgSender mqttMsgSender
var WsMsgSender wsMsgSender

const (
	CmdToGateway   = "CmdToGateway" //直接由网关处理的命令
	CmdFromGateway = "CmdFromGateway"
	CmdFromDev     = "CmdFromDev"
	CmdToDev       = "CmdToDev"

	SubCmdToGw_AddDev             = "addDev"
	SubCmdToGw_CancelAddDev       = "cancelAddDev"
	SubCmdToGw_QueryGatewayStatus = "queryGatewayStatus"
	SubCmdToGw_DelDev             = "delDev"
	SubCmdFromGw_HeartDev		  = "heartDev" 		// 网关心跳
	SubCmdFromGw_Online           = "online"
	SubCmdFromGw_Offline          = "offline"
	SubCmdFromGw_DevAddSuccess    = "devAddSuccess"
	SubCmdFromGw_DevAddCanceled   = "devAddCanceled"
	SubCmdFromGw_DelDevSuccess    = "delDevSuccess"
	SubCmdFromGw_PassThrough      = "passThrough" 	// 透传网关发给前端的消息

	SubCmdFromDev_SetKv      = "setKv"     			//设置kv
	SubCmdFromDev_UploadLog  = "uploadLog" 			//上传日志
	SubCmdFromDev_CmdFromDev = "cmdFromDev"
	SubCmdToDev_CmdToDev     = "cmdToDev"
)

//mqtt与weebsocekt上的数据包格式
type MqttMsg struct {
	Cmd       string
	SubCmd    string
	Data      string
	GatewayId string
	DevId     string
}

type mqttMsgSender interface {
	SendMsg(msg *MqttMsg) t11Errors.T11Error
	GetGatewayOnlineStatus(gatewayId string) bool
}

type wsMsgSender interface {
	SendMsg(tk *models.JwtToken, msg *MqttMsg) t11Errors.T11Error
}

type MqMsg struct {
	ClientId string
	Topic    string
	Data     string
}
